package com.cpit.qualitycontrol.service;

import java.util.List;
import java.util.Map;

/**
 * Created by xxx on 2017/10/1.
 */
public interface ActivitiService {

    /**
     * 创建工单
     *
     * @param createUserId 创建人用户ID
     * @return 创建的工单流程实例ID
     */
    String createWorkOrder(Integer createUserId, String businessKey);

    /**
     * 根据用户ID 查询待派发工单的流程实例ID
     *
     * @return list<流程实例               id>
     */
    List<String> queryNotAssingTask();

    /**
     * 根据用户ID 查询待处理ExecutionIDs
     *
     * @param userId
     * @return
     */
    List<String> queryTaskExecutionIDByUserId(Integer userId, String organizationTeamCode, boolean isEnginnerDept);


//    /**
//     * 签收任务
//     *
//     * @param userId
//     * @param taskDefinitionKey
//     */
//    void claim(Integer userId, String taskDefinitionKey, String processInstanceBusinessKey) throws Exception;

    /**
     * 分派任务
     *
     * @param processInstanceBusinessKey
     * @param assignUserId               分派人
     * @param organizationTeamMap        key = 施工队组织机构ID-subtaskId, value = 施工队code
     * @return key = 施工队组织机构ID-subtaskId, value = actTask.getExecutionId() + ":" + actTask.getId()
     */
    Map<String, String> assignWorkOrder(String processInstanceBusinessKey,
                                        Integer assignUserId,
                                        Map<String, String> organizationTeamMap) throws Exception;


    String queryTaskId(String actProcInstId, String actExecutionId, Integer userId, String taskDefinitionKey);

    /**
     * 完成施工任务，并返回审核任务ID
     *
     * @param actTaskId
     * @return actCheckTaskId
     */
    void completeConstructTask(String actTaskId, Boolean isCheck);

    /**
     * 完成审核任务
     *
     * @param actTaskId
     * @param isAccred          是否通过
     * @param organizationTeamCode 不通过驳回继续施工
     */
    void completeCheckTask(String actTaskId, Boolean isAccred, String organizationTeamCode);

    /**
     * @param userId
     * @param actTaskId
     */
    void claimTask(Integer userId, String actTaskId);

    /**
     * 判断流程实例是否结束
     *
     * @param processInstanceId
     * @return
     */
    public Boolean isProcessInstanceEndById(String processInstanceId);

    /**
     * 根据userId 查询历史 ExecutionId
     *
     * @param userId
     * @return
     */
    public List<String> queryHistoryTaskExecutionIdsByUserId(Integer userId, String organizationTeamCode);

}
